package itheima.com.socketdemo1;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetadressDemo1 {
    public static void main(String[] args) throws UnknownHostException {
//        static InetAddress.getByName(String host)
//                                      确定主机名称的ip地址，主机名称可以是机器名称，也可以是
//        String getHostName()          获取此IP地址的主机名称
//        String getHostAddress()         返回文本显示中的IP地址字符串

        InetAddress address = InetAddress.getByName("黑马嘿嘿嘿");
        System.out.println(address);

        String hostName = address.getHostName();
        System.out.println("主机名为"+hostName);

        String hostAddress = address.getHostAddress();
        System.out.println("IP地址为"+hostAddress);
    }
}
